import axios from './ajax';
import type { RESDataType } from './ajax';

export async function getUserInfo(): Promise<RESDataType> {
  const res = await axios.get('/api/user/info');
  return res;
}

export async function register(
  username: string,
  password: string,
  nickname?: string
): Promise<RESDataType> {
  const data = { username, password, nickname: nickname || username };
  const res = await axios.post('/api/user/register', data);
  return res;
}
export async function login(
  username: string,
  password: string
): Promise<RESDataType> {
  const data = { username, password };
  const res = await axios.post('/api/user/login', data);
  return res;
}
